package Leetcode.string;

public class Reverseint {
    public int reverse(int x) {
        if(x==0 ||x>Integer.MAX_VALUE || x<Integer.MIN_VALUE)
          return 0;

        long result=0;
        while (x!=0){
             x=x/10;
            result=result*10+x%10;
        }
        if(result>Integer.MAX_VALUE || result<Integer.MIN_VALUE)
            return 0;

        return (int)result;
    }


    public static void main(String[] args) {
        int x=1534236469;

        Reverseint reverseint=new Reverseint();
        System.out.println(reverseint.reverse(x));
        //System.out.println(Integer.MAX_VALUE);



    }
}
